package controllers

import (
	"github.com/gin-gonic/contrib/sessions"
	"github.com/gin-gonic/gin"
	"net/http"
)

type ControllerInterface interface {
	Post(context *gin.Context)
	Get(context *gin.Context)
	Delete(context *gin.Context)
	Patch(context *gin.Context)
	Put(context *gin.Context)
	Options(context *gin.Context)
	Head(context *gin.Context)
	GetControllerMethod() []string
	GetControllerName() string
	GetSchema() string
	SetRotuers(srv *http.Server)
	Handler()
}

var (
	MethodHttpGet     = "Get"
	MethodHttpPost    = "Post"
	MethodHttpDelete  = "Delete"
	MethodHttpPatch   = "Patch"
	MethodHttpPut     = "Put"
	MethodHttpOptions = "Options"
	MethodHttpHead    = "Head"
)

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
type Controller struct {
	web *http.Server
}

func (c *Controller) Post(context *gin.Context) {
	context.Status(404)
}
func (c *Controller) Get(context *gin.Context) {
	context.Status(404)
}
func (c *Controller) Delete(context *gin.Context) {
	context.Status(404)
}
func (c *Controller) Patch(context *gin.Context) {
	context.Status(404)
}
func (c *Controller) Put(context *gin.Context) {
	context.Status(404)
}
func (c *Controller) Options(context *gin.Context) {
	context.Status(404)
}
func (c *Controller) Head(context *gin.Context) {
	context.Status(404)
}
func (c *Controller) GetSessionKV(context *gin.Context, key interface{}) interface{} {
	session := sessions.Default(context)
	return session.Get(key)
}
func (c *Controller) SetSessionKV(context *gin.Context, key interface{}, val interface{}) {
	session := sessions.Default(context)
	session.Set(key, val)
}
func (c *Controller) DelSessionKV(context *gin.Context, key interface{}) {
	session := sessions.Default(context)
	session.Delete(key)
}
func (c *Controller) SaveSession(context *gin.Context) {
	session := sessions.Default(context)
	session.Save()
}
func (c *Controller) GetControllerMethod() []string {
	return []string{"get", "post", "put", "delete"}
}
func (c *Controller) GetControllerName() string {
	return "Controller"
}
func (c *Controller) GetSchema() string {
	return "error"
}
func (c *Controller) SetRotuers(web *http.Server) {

	c.web = web
}
func (c *Controller) Handler() {

}

func (c *Controller) ServiceFinish(context *gin.Context, status int, res *Response) {

	context.JSON(status, res)
}
